#!/bin/bash

SH_BASE=`dirname $0`/../
SCR=`find $SH_BASE -name scr.exp`

TGTSVR="$1"
[ -z "$TGTSVR" ] && exit 1
# check if target exits
ping -c 1 -q $TGTSVR 1>/dev/null 2>&1
[ "$?" != "0" ] && exit 1

function run_target_cmd()
{
    CMD="$1"
    $SCR iforgot root@$TGTSVR "~" "$CMD"
}

SEP="--------------------------------------------------------------"

echo "     Opearting Systems"
echo $SEP
run_target_cmd "rpm -qf /etc/issue" |  awk '($0 ~ /redhat.+release|sles.+release/){print $0}'
run_target_cmd "uname -a" |  grep Linux | grep GNU

echo ""
echo "     Hardware Platform"
echo $SEP
run_target_cmd "dmidecode -t 1 -t 0 " | awk -F':' '($1 ~ /Product Name|Serial Number|UUID|SKU Number|BIOS Revision|Firmware Revision|Socket Designation|Part Number|Status/){print $0}'  

echo ""
echo "     CPU"
echo $SEP
run_target_cmd "cat /proc/cpuinfo" | awk -F':' '( $1 ~ /model name|processor|cpu MHz/ ){print $0}'

echo ""
echo "     Memory"
echo $SEP
run_target_cmd "cat /proc/meminfo" | awk '( $1 ~ /MemTotal:|MemFree:/){print $0}' 


